package com.example.arithmeticleetcode.leetcode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-06-19 09:29
 **/
public class Demo32 {

    public static void main(String[] args) {
//        String str = "abbxxxxzzy";
//        System.out.println(str.charAt(0));
//        System.out.println(1<<1);
        String str = "abbxxxxzzy";
        String str1 = "abc";
        String str2 = "abcdddeeeeaabbbcd";
        largeGroupPositions(str);
        largeGroupPositions(str1);
        largeGroupPositions(str2);
        System.out.println(0 ^ 2 ^ 4 ^ 6 ^ 8);
    }

    public static List<List<Integer>> largeGroupPositions(String S) {
        S = S + "A";
        List<List<Integer>> result = new ArrayList<>(S.length());
        List<Integer> list = null;
        int begin = 0;
        for (int i = 1, len = S.length(); i < len; i++) {
            if (S.charAt(i) != S.charAt(i - 1)) {
                if (i - begin >= 3) {
                    list = new ArrayList<>(1 << 1);
                    list.add(begin);
                    list.add(i - 1);
                    result.add(list);
                }
                begin = i;
            }

        }
        return result;
    }
}
